package cn.tedu.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.tedu.entity.Emp;
import cn.tedu.service.EmpService;
import cn.tedu.util.JsonResult;

@Controller
@RequestMapping("/emp")
public class EmpController {
	
	@Resource
	private EmpService empSevice;
	
	@RequestMapping("/empList.do")
	@ResponseBody
	public JsonResult<List<Emp>> emoListExecute(){
		JsonResult<List<Emp>> result = empSevice.empList();
		return result;
	};
	
	@RequestMapping("/addEmp.do")
	@ResponseBody
	public JsonResult<Object> addEmpExecute(String name, String salary, String age){
		
		JsonResult<Object> addEmp = empSevice.addEmp(name, salary, age);
		return addEmp;
				
	}
	
	@RequestMapping("/deleteEmp.do")
	@ResponseBody
	public JsonResult<Object> deleteEmpExecute(int id){
		JsonResult<Object> result = empSevice.deleteEmp(id);
		return result;
	}
	
	@RequestMapping("/findByIdEmp.do")
	@ResponseBody
	public JsonResult<Object> EmpExecute(int id){
		JsonResult<Object> result = empSevice.findById(id);
		return result;
	}
	@RequestMapping("/updateEmp.do")
	@ResponseBody
	public JsonResult<Object> updateEmpExecute(int id,String name, double salary,int age){
		JsonResult<Object> result = empSevice.updateEmp(id, name, salary, age);
		return result;
	}
}
